<?php
include 'config/config.php';
include 'lib/promo.php';
include 'lib/member.php';
include 'lib/produk.php';

$config=new config();
$config->connect();

$Promo_Dao=new Promo_Dao();
$data2=$Promo_Dao->get_aktif();
$data =array_slice($data2,0,12);
//echo count($data);

$Member_Dao=new Member_Dao();
$members=$Member_Dao->get_all();


?>
<?php include("header.php") ?>
<?php include("menu_kiri.php") ?>

<div id="body">
<div class="topbox">

<p><h1><b>Selamat datang di hot-L.com</b></h1></p>
                      <h4><p>Terus akses situs ini untuk mendapatkan informasi mengenai promo hotel terbaru 
					  dan pencarian hotel untuk tujuan wisata atau bisnis Anda.</p></h4>
               
</div>
<div class="slider">
	 <div class="slider-wrapper theme-default">
            <div id="slider" class="nivoSlider">
			<?php foreach($members as $Member){
				if($Member->foto_member!=""){
                echo "<a href=\"detil_hotel.php?id=$Member->id\"><img src=\"member/images/hotel/$Member->foto_member\" alt=\"\" title=\"".ucwords($Member->nama)."\"/></a>";
				}
            }?>
            </div>
            <div id="htmlcaption" class="nivo-html-caption">
            </div>
     </div>
	 <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="js/jquery.nivo.slider.js"></script>
    
	<script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
	$('div.nivoSlider').nivoSlider({
    //directionNav:false,
    controlNav:false,
    keyboardNav:false
	});
	
    </script>
	
</div>
<div class="menubox">
                
				  <br/> 
				  <h1>Daftar Promo Hotel Terbaru</h1>
                  <br/>        
</div>    

 <?php
if (count($data)!=0){
	$i=1;
	foreach($data as $dt){
	$Member_Dao=new Member_Dao();
	$member=$Member_Dao->get_id($dt->id);
	//echo $member->id;			
	$Produk_Dao=new Produk_Dao();
	$produk=$Produk_Dao->get_id($dt->id_produk);
					
	$tgl_mulai = date("d-M-Y", strtotime($dt->tgl_mulai));
	$tgl_selesai = date("d-M-Y", strtotime($dt->tgl_selesai));
	
	echo "<div class=\"leftbox\">"; 	
					echo "<a href=\"detil_produk.php?id=$dt->id_produk\"><p><h5><b>".ucwords($produk->nama_produk)." Room"."</b></h5></p></a>";
					
					if($produk->foto_produk!=""){
					echo "<a href=\"detil_produk.php?id=$dt->id_produk\"><img src=\"member/images/produk/$produk->foto_produk\" width=\"241\" height=\"150\" 
					class=\"left\" /></a><br/>";
					}else{
					echo "<img src=\"images/kamar.jpeg\" width=\"241\" height=\"150\" class=\"left\" /><br/>";
					}
					echo "<div class=\"clear\"></div>";
					echo "<p>Waktu: ".$tgl_mulai." s.d. ".$tgl_selesai."</p>";
					echo "<p>Harga: Rp".number_format($dt->harga_promo, 2, '.', ',')."  "." <del>Rp".number_format($produk->harga, 2, '.', ',').".</del></p>";
					 
					echo "<p class=\"readmore\"><a href=\"detil_promo.php?id=$dt->id_promo\"><input type=\"button\" value=\"detil\"></a></p>";
					//echo "<p>".$dt->keterangan_promo."</p>"; 
					
	echo "</div>";
	$i++;}
	echo "<div class=\"topbox\"><a href=\"daftar_promo_hotel.php\">Lihat selengkapnya</a></div>";
	} else {
	echo "<div class=\"topbox\">Tidak ada promo hotel saat ini.</div>";
	}	
?>
</div>
          
         <div class="clear"></div>
         <?php include("footer.php") ?>
		